<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head th:replace="common/fragment::top">

</head>

<body>
<div class="lyear-layout-web">
    <div class="lyear-layout-container">
        <!--左侧导航-->
        <div th:replace="common/fragment::leftmenu"></div>
        <!--End 左侧导航-->

        <!--头部信息-->
        <div th:replace="common/fragment::header"></div>
        <!--End 头部信息-->

        <!--页面主要内容-->
        <main class="lyear-layout-content">

            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="card">
                            <div class="card-toolbar clearfix">
                                <form action="" class="pull-right search-bar" method="get" role="form">
                                    <div class="input-group">
                                        <div class="input-group-btn">
                                            <input id="search-field" name="search_field" type="hidden" value="title">
                                            <button aria-expanded="false" aria-haspopup="true"
                                                    class="btn btn-default dropdown-toggle" data-toggle="dropdown" id="search-btn"
                                                    type="button">
                                                名称 <span class="caret"></span>
                                            </button>
                                            <ul class="dropdown-menu">
                                                <li><a data-field="title" href="javascript:void(0)" tabindex="-1">名称</a>
                                                </li>
                                            </ul>
                                        </div>

                                        <input class="form-control" id="keyword-find-rolename" name="keyword" placeholder="请输入名称" type="text"
                                               value="">
                                        <span class="input-group-btn">
                                              <button class="btn btn-primary" id="keyword-find-btn" onclick="keywordsearch()"
                                                      type="button">搜索</button>
                                            </span>

                                    </div>
                                </form>

                                <div class="toolbar-btn-action">
                                    <a class="btn btn-primary m-r-5" href="/good/addgood.do">
                                        <i class="mdi mdi-plus"></i>
                                        新增
                                    </a>
                                    <!--
                                    <a class="btn btn-success m-r-5" href="#!"><i class="mdi mdi-check"></i> 启用</a>
                                    <a class="btn btn-warning m-r-5" href="#!"><i class="mdi mdi-block-helper"></i> 禁用</a>
                                    <a class="btn btn-danger" href="#!"><i class="mdi mdi-window-close"></i> 删除</a>
                                    -->
                                </div>
                            </div>
                            <div class="card-body">
                                <div class="table-responsive">
                                    <table class="table table-bordered">
                                        <thead>
                                        <tr>
                                            <th>序号</th>
                                            <th hidden="hidden">id</th>
                                            <th>名称</th>
                                            <!--    <th>角色图标</th>-->
                                            <th>商品规格</th>
<!--                                            <th>包装</th>-->
                                            <th>计量单位</th>
                                            <th>状态</th>
                                            <th>备注</th>
                                            <th>操作</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr th:each="good:${goodlist}">

                                            <td th:text="${goodStat.index+1}"></td>
                                            <td hidden="hidden" th:text="${good.id}"></td>

                                            <td th:text="${good.name}"></td>
                                            <td th:text="${good.spec}"></td>
<!--                                            <td th:text="${good.pk}"></td>-->
                                            <td th:text="${good.unit}"></td>
                                            <td th:switch="${good.status}">
                                                <i style="color: #0FB25F" th:case="1" th:text="启用"></i>
                                                <i style="color: #985f0d;" th:case="-1" th:text="禁用"></i></td>
                                            </td>

                                            <td th:text="${good.comment}"></td>

                                            <td>
                                                <div class="btn-group">
                                                    <a class="btn btn-xs btn-default editgood"
                                                       data-toggle="tooltip"
                                                       th:href="@{${good.id}}" title="编辑">
                                                        <i class="mdi mdi-pencil"></i>
                                                    </a>
                                                    <a class="btn btn-xs btn-default forbidden"
                                                       data-toggle="tooltip"

                                                       th:href="@{${good.id}}" title="禁用">
                                                        <i class="mdi mdi-alert-outline"></i>
                                                    </a>
                                                </div>
                                            </td>
                                        </tr>

                                        </tbody>
                                    </table>
                                </div>

                            </div>
                        </div>
                    </div>

                </div>

            </div>
        </main>
        <!--End 页面主要内容-->
        <!--End 页面主要内容-->
    </div>
</div>
<div th:replace="common/fragment::tail-script"></div>
<script type="text/javascript">


    $(document).ready(function () {
            // 禁用按钮 -- 提交后台切换状态为禁用
            $('.forbidden').each(function (i,e) {
                // console.log($(e).attr('href'))
                $(e).click(function (ev) {
                    let id = $(this).attr('href');
                    post_ajax("/good/goodforbidden.ajax",{id:id},"/good/goodlist.do")
                    ev.preventDefault();
                })
            });

            // 编辑good按钮 editgood
        $('.editgood').each(function (i,e) {
            // console.log($(e).attr('href'))
            $(e).click(function (ev) {
                let id = $(this).attr('href');
                window.location.href="/good/editgood.do?id="+id
                ev.preventDefault();
            })
        });



        }
    );

</script>
</body>
</html>